package main

import (
	"myapp/controllers"
	"myapp/models"
	_ "myapp/routers"

	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
)

func init() {
	models.RegisterDB()

	orm.RegisterDriver("mysql", orm.DRMySQL)
	/*
			db, err := sql.Open("mysql", "user:password@tcp(localhost:5555)/dbname?charset=utf8")
		其中连接参数可以有如下几种形式：
		user@unix(/path/to/socket)/dbname?charset=utf8
		user:password@tcp(localhost:5555)/dbname?charset=utf8
		user:password@/dbname
		user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname*/
	//orm.RegisterDataBase("default", "mysql", "slave:slave@tcp(54json.com:3306)/test?charset=utf8")
}
func main() {
	//orm.Debug = true
	//自动建表1数据库名称，2是否删掉重建，3是打印信息
	//orm.RunSyncdb("default", false, false)

	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})

	beego.Run()
}
